package com.tx.logsys.restbean;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName: CommonResponse
 * @Author: ...
 * @Description: 响应结果
 * @Date: 2019/7/19 11:01
 * @Version: 1.0
 */
public class CommonResponseBK {

    private int code = 20000;
    private String message = "";
    private Object data;

    /**
     * 构造0
     */
    public CommonResponseBK() {
    }

    /**
     * 构造1
     *
     * @param code
     * @param message
     * @param data
     */
    public CommonResponseBK(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    /**
     * 构造2
     *
     * @param token
     */
    public CommonResponseBK(Integer token) {
        Map<String, Object> map = new HashMap<>();
        map.put("token", token);
        this.data = map;
    }

    /**
     * 构造3
     *
     * @param code
     * @param message
     */
    public CommonResponseBK(int code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 构造4
     *
     * @param data
     */
    public CommonResponseBK(Object data) {
        this.data = data;
    }

    /**
     * 构造5
     *
     * @param errorCode
     */
    public CommonResponseBK(ErrorCode errorCode) {
        this.code = errorCode.getValue();
        this.message = errorCode.getDesc();
    }

    /**
     * 初始化data为map并返回
     *
     * @return
     */
    public Map mapData() {
        this.data = new HashMap<String, Object>();
        return (Map) this.data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }


}
